package controller.api;
import com.jfinal.aop.Clear;
import com.jfinal.aop.Inject;

import common.inter.WxUserInter;
import common.kit.IpKits;
import service.WxuserService;

public class ApiWxuserController extends BaseApiController {
	@Inject WxuserService wxuserService ;

	@Clear(WxUserInter.class)
	public void checkLogin() {
		String ip = IpKits.getFirstIp(getRequest());
		String token = getRequest().getHeader("token");
	    renderJson(wxuserService.checkLogin(token , ip));
    }
	
	@Clear(WxUserInter.class)
	public void login() {
		String encryptedData = getPara("encryptedData");
		String iv = getPara("iv");
		String jsCode = getPara("js_code");
		String ip = IpKits.getFirstIp(getRequest());
	    renderJson(wxuserService.login(jsCode , encryptedData , iv , ip));
    }
	
	public void info() {
		renderJson(wxuserService.info(getWxuser()));
	}
}
